//@author A0101038Y
//Filemanager.h is the header file for Filemanager.cpp
#ifndef FILEMANAGER_H
#define FILEMANAGER_H
#include <fstream>
#include <vector>
#include <sstream>
#include <Entry.h>
#include <EntryManager.h>
#include <Task.h>
#include <Event.h>
#include <CommonUtils.h>
using namespace std;
class FileManager
{
	ifstream _inFile;
	ofstream _outFile;
	vector<Entry*> _entries;
	string _fileName;
	
	void loadEntries();//Loads file contents into entry vector
	
	void loadLineToVector();
	


	//this function updates file with the entries vector
	//pre-req: NIL
	//post-req: NIL
	void updateFile();
	
	//this function writes string to file
	//pre-req: NIL
	//post-req: NIL
	void writingToFile();
	
	//this function loads entry type
	//pre-req: NIL
	//post-req: NIL
	void loadEntryType(string &);
	
	//this function loads string of Task to vector
	//pre-req: NIL
	//post-req: NIL
	void loadContentTask(string &, string &);
	
	//this function loads string of Entry to vector
	//pre-req: NIL
	//post-req: NIL
	void loadContentEvent(string &, string &);

protected:
	FileManager(string);
public:
	static FileManager& getInstance(string);

	~FileManager(void);
		
	
	virtual vector<Entry*> getEntries();//returns the loaded vector
	virtual void updateFromVector(vector<Entry*>);
};

#endif